<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="layout" content="main"/>
  <title>My Events</title>
</head>
<body>
<div class="body">
  <h1>My Events</h1>
  <g:if test="${flash.message}">
    <div class="message">${flash.message}</div>
  </g:if>
  <g:if test="${eventInstanceList}">
    <div class="list">
      <table>
        <thead>
        <tr>
          <g:sortableColumn property="name" title="Name"/>
          <g:sortableColumn property="description" title="Description"/>
          <g:sortableColumn property="startDate" title="Start Date"/>
          <g:sortableColumn property="endDate" title="End Date"/>
          <th></th>
          <th></th>
          <th></th>
        </tr>
        </thead>
        <tbody>
        <g:each in="${eventInstanceList}" status="i" var="eventInstance">
          <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
            <td>${fieldValue(bean: eventInstance, field: 'name')}</td>
            <td>${fieldValue(bean: eventInstance, field: 'description')}</td>
            <td>${fieldValue(bean: eventInstance, field: 'startDate')}</td>
            <td>${fieldValue(bean: eventInstance, field: 'endDate')}</td>
            <td><g:link action="edit" id="${eventInstance.id}">Edit Event</g:link></td>
            <td><g:link controller="eventPosition" action="create" id="${eventInstance.id}">Add Position</g:link></td>
            <td><g:link action="delete" id="${eventInstance.id}" onclick="return confirm('Are you sure you want to delete event?');">Delete Event</g:link></td>
          </tr>
        </g:each>
        </tbody>
      </table>
    </div>
    <div class="paginateButtons">
      <g:paginate total="${eventInstanceTotal}"/>
    </div>
  </g:if>
  <g:else>
    <div class="message">You do not have any events!</div>
  </g:else>
</div>
</body>
</html>